/**
 * 评论模块
 */
import request from '@/utils/request'

/**
 * 获取评论
 * @param {Object} params {type  source  offset limit }
 * @returns promise
 */
export const getArticleComment = params => {
  return request({
    method: 'GET',
    url: '/v1_0/comments',
    params
  })
}

/**
 * 对评论或评论回复点赞
 * @param {Number} target 评论id
 * @returns promise
 */
export const getCommentLiking = target => {
  return request({
    method: 'POST',
    url: '/v1_0/comment/likings',
    data: {
      target
    }
  })
}

/**
 * 取消评论或评论回复点赞
 * @param {Number} target 评论id
 * @returns promise
 */
export const deleteCommentLiking = target => {
  return request({
    method: 'DELETE',
    url: '/v1_0/comment/likings/' + target
  })
}

/**
 *
 * @param {Object} data {}
 * target 评论文章即为文章id，对评论进行回复则为评论id
 * content 评论内容
 * art_id 文章id，对评论内容发表回复时，需要传递此参数，表明所属文章id。对文章进行评论，不要传此参数。
 * @returns promise
 */
export const CommentPost = data => {
  return request({
    method: 'POST',
    url: '/v1_0/comments',
    data
  })
}
